package com.leyou.order.web;

import com.leyou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private OrderService orderService;

    /**
     * springMVC： 会自动根据请求方式，把返回值转成XML
     * @return
     */
    @PostMapping(value="/notify", produces = "application/xml")
    public ResponseEntity<Map<String, String>> wxnotify(@RequestBody // 把xml参数转成对象
                                                                    Map<String ,String> wxmsg){
        System.out.println("C微信通知我们了。。。。。。。");
        Map<String , String> msg = orderService.wxnotify(wxmsg);

        return ResponseEntity.ok(msg);
    }
}
